package com.wtpaint.design.creational.singleton;

/**
 * 双重检查模式
 */
public class LazyDoubleCheckSingleton {

    private static LazyDoubleCheckSingleton lazySingleton = null;

    private LazyDoubleCheckSingleton() {

    }

    public static LazyDoubleCheckSingleton getInstance() {
        if (null == lazySingleton)
            synchronized (LazyDoubleCheckSingleton.class) {
                if (null == lazySingleton) {
                    //1.分配内存
                    //2.初始化对象
                    //3.指向地址
                    lazySingleton = new LazyDoubleCheckSingleton();
                }
            }
        return lazySingleton;
    }
}
